package com.dingding.transfer.stamper.service.impl;

import com.dingding.transfer.stamper.dao.ImageRecordDao;
import com.dingding.transfer.stamper.dto.BaseResult;
import com.dingding.transfer.stamper.dto.BaseResultFactory;
import com.dingding.transfer.stamper.dto.InfoImageReq;
import com.dingding.transfer.stamper.entity.ImageRecord;
import com.dingding.transfer.stamper.service.CmdStrategy;
import com.dingding.transfer.stamper.util.SpringContextUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * @author wangxiyuan
 * @description
 * @createDate 2021/4/7 9:58
 **/
@Slf4j
public class InfoImageReqStrategy implements CmdStrategy {
    @Override
    public BaseResult handle(Object object) {
        log.info("加盖印章图片回调开始");
        InfoImageReq infoImageReq = (InfoImageReq) object;
        if(infoImageReq.getType() == 0){
            ImageRecordDao imageRecordDao = SpringContextUtil.getBean(ImageRecordDao.class);
            ImageRecord imageRecord = new ImageRecord();
            imageRecord.setMark(infoImageReq.getMark());
            imageRecord.setFileUrl(infoImageReq.getHost() + infoImageReq.getPath());
            imageRecordDao.insert(imageRecord);
        }
        return BaseResultFactory.produceSuccess();
    }
}
